package com.tony.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;


@Component
@Aspect
public class AspectjHelper {
    @After(value = "execution(* com.tony.*..*.*(..))")
    public void afterMethod(){
        System.out.println("this is after");
    }

    @Before(value = "execution(* com.tony.*..*.*(..))")
    public void before(JoinPoint joinPoint){
        Object[] objs = joinPoint.getArgs();
        for(Object obj:objs){
            System.out.println("###########"+obj.toString());
        }

        System.out.println("this is before");
    }

    @Around(value = "execution(* com.tony.*..*.*(..))")
    public void aroundMethod(ProceedingJoinPoint pjp) throws Throwable{
        Object returnObj = pjp.proceed();
        System.out.println("返回值："+returnObj);
    }

    @AfterReturning(value = "execution(* com.tony.*..*.*(..))")
    public void afterReturnMethod(){
        System.out.println("@@@@@afterReturnMethod...");
    }
}
